<?php

namespace frontend\controllers;

/*
**Team :
**Coding by 曾钰媛 1511240 170706
**This is the article controller
*/
use Yii;
use common\models\PreAdminArticle;
use frontend\models\PreAdminArticleSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;

class PreAdminArticleController extends \yii\web\Controller
{
    public function actionIndex()
    {
		$this->layout="main";
		 $searchModel = new PreAdminArticleSearch();
        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);

        return $this->render('index', [
            'searchModel' => $searchModel,
            'dataProvider' => $dataProvider,
        ]);
        return $this->render('index');
    }
	
	public function actionView($id)
    {
		$this->layout="main";
        return $this->render('view', [
            'model' => $this->findModel($id),
        ]);
    }
	
	protected function findModel($id)
    {
        if (($model = PreAdminArticle::findOne($id)) !== null) {
            return $model;
        } else {
            throw new NotFoundHttpException('The requested page does not exist.');
        }
    }

}
